home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5121 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  58 lines

  1. Path: zetnet.co.uk!demon!exel.demon.co.uk
  2. From: Jason Hambleton <jkh@exel.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: ANSI var-arglist processing
  5. Date: Fri, 09 Feb 1996 10:16:18 +0000
  6. Organization: Exel Computer Systems
  7. Message-ID: <311B1EF2.7673@exel.co.uk>
  8. NNTP-Posting-Host: exel.demon.co.uk
  9. X-NNTP-Posting-Host: exel.demon.co.uk
  10. X-Mailer: Mozilla 2.0 (Win95; I)
  11. MIME-Version: 1.0
  12. Content-Type: text/plain; charset=us-ascii
  13. Content-Transfer-Encoding: 7bit
  14.  
  15. HHHEEEEEEELLLLPPPP!!!!
  16.  
  17. Can anybody tell me how to do this in *ANSI* (I can get it to
  18. work perfectly in NON_ANSI).
  19.  
  20. I'm trying to call a function will a var-arglist, do nothing with it,
  21. and then pass the arg-list through to another function.
  22.  
  23. Heres the code I'm trying to get working.
  24.  
  25. Jason Hambleton
  26. jkh@exel.co.uk
  27. Exel Computer Systems, Nottingham (UK)
  28.  
  29.  
  30.  
  31.  
  32. #include "stdio.h"
  33. #include "stdarg.h"
  34.  
  35. func2(char *fmt, ...)
  36. {
  37.     va_list args;
  38.     char buffer[81];
  39.  
  40.     va_start(args, fmt);
  41.     vsprintf(buffer, fmt, args);
  42.     va_end(args);
  43.  
  44.     printf("RESULT = (%s)\n", buffer);
  45. }
  46.  
  47. func1(char *fmt, ...)
  48. {
  49.     /* How do I pass the arg-list from here, to the next function */
  50.  
  51.     func2(fmt, ????????);
  52. }
  53.  
  54. main()
  55. {
  56.     func1("test %d", 45);
  57. }
  58.